<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="de.openlaboratory.elib.model.library.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
	<title>Publication Servlet</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%
	Publication publication = (Publication) request.getAttribute("publication");
	String forwardAction = (String) request.getAttribute("elib_action");
%>
	<form action="publication" method="post">
		<input type="hidden" name="elib_repository" value="<%= request.getAttribute("elib_repository") %>" />
		<input type="hidden" name="elib_ns" value="<%= Publication.class %>" />
		<input type="hidden" name="id" value="<%= publication.getId() %>" />
		<input type="hidden" name="elib_action" value="<%= request.getAttribute("elib_action") %>" />
		
           <h1>Edit Publication</h1>
		<p>
			<label for="title">Publication Title</label>
			<input id="title" name="title" value="${ publication.title }" />
			<span class="error">${messages.title}</span>
		</p>
		<p>
			<label for="subtitle">Subtitle</label>
			<input id="subtitle" name="subtitle" value="${ publication.subtitle }" />
			<span class="error">${messages.subtitle}</span>
		</p>
		<p>
			<label for="author">Author(s)</label>
			<input id="author" name="author" value="${ publication.author }" />
			<span class="error">${messages.author}</span>
		</p>
		<p>
			<select name="library_id" size="1">
			<c:forEach items="${libraries}" var="library">
				<option value="${library.id}"<c:if test="${library.id eq publication.libraryId}"> selected="selected"</c:if>>${library.name}</option>
	        </c:forEach>
				
	    	</select>
		</p>
		<p>
		Authors: <br />
		<c:forEach items="${authors}" var="author">
			<input type="checkbox" name="authors" value="${author.id}"
			<c:forEach items="${publication.authors}" var="pers">
				<c:if test="${pers.id eq author.id}"> checked</c:if>
	        </c:forEach>
	        />${author.name}<br />
	    </c:forEach>
		</p>
		<p>
			<input type="submit">
			<span class="success">${messages.success}</span>
		</p>
	</form>
</body>
</html>